<template>
  <scroll-view
    :scroll-x="scroll.x"
    :scroll-y="scroll.y"
    class="scroll-container"
    :class="className"
  >
    <van-grid :border="false">
      <van-grid-item
        icon="/static/icons/message.png"
        text="消息"
      />
      <van-grid-item
        icon="/static/icons/shop.png"
        text="订单"
      />
      <van-grid-item
        icon="/static/icons/dangan.png"
        text="报名"
      />
      <van-grid-item
        icon="/static/icons/star.png"
        text="收藏"
      />
    </van-grid>
    <!-- 话题讨论 -->
    <group-cell
      title="话题大讨论"
      value="更多"
    >
      <block>
        <scroll-view
          :scroll-x="true"
          :enable-flex="true"
          scroll-left="15px"
          class="horizontal-scroll-container"
        >
          <view
            class="topic-item"
            v-for="(item,index) in topics"
            :key="index"
          >
            <image
              :src="item.thumb"
              mode="aspectFill"
            />
            <div class="topic-item-content">
              <h2 class="topic-item__title">{{item.title}}</h2>
              <div class="topic-item__extend">
                <span>
                  <van-tag
                    round
                    type="primary"
                    v-if="item.tag"
                  >{{item.tag}}</van-tag>
                </span>
                <span>{{item.partakes}}人热聊</span>
              </div>
            </div>
          </view>
        </scroll-view>
      </block>
    </group-cell>
    <div>
      <van-cell
        :border="false"
        size="large"
        center
        title="话题大讨论"
        value="更多"
        custom-class="category-cell"
      />
      <scroll-view
        :scroll-x="true"
        :enable-flex="true"
        scroll-left="15px"
        class="horizontal-scroll-container"
      >
        <view
          class="topic-item"
          v-for="(item,index) in topics"
          :key="index"
        >
          <image
            :src="item.thumb"
            mode="aspectFill"
          />
          <div class="topic-item-content">
            <h2 class="topic-item__title">{{item.title}}</h2>
            <div class="topic-item__extend">
              <span>
                <van-tag
                  round
                  type="primary"
                  v-if="item.tag"
                >{{item.tag}}</van-tag>
              </span>
              <span>{{item.partakes}}人热聊</span>
            </div>
          </div>
        </view>
      </scroll-view>
    </div>
    <!-- 加入云团 -->
    <div
      class="yuntuan"
      v-if="yuntuan"
    >
      <van-cell-group
        class="yuntuan-group"
        :border="false"
      >
        <h2 class="yuntuan-catename">
          {{yuntuan.title}}
          <small>{{yuntuan.description}}</small>
        </h2>
        <van-cell
          :title="group.title"
          :icon="group.thumb"
          :border="false"
          v-for="(group,index) in yuntuan.groups"
          :key="index"
        />
      </van-cell-group>
      <div class="yuntuan-box">
        <div class="yuntuan-avatars">
          <span
            v-for="(avatar,index) in yuntuan.avatars"
            :key="index"
          >
            <image
              :src="avatar"
              mode="aspectFill"
            />
          </span>
        </div>
        <div class="yuntuan-mark">{{yuntuan.mark}}</div>
        <van-button
          round
          type="info"
          size="small"
        >{{yuntuan.link}}</van-button>
      </div>
    </div>
    <!-- 装备库 -->
    <div>
      <van-cell
        :border="false"
        size="large"
        center
        title="运动装备库"
        value="更多"
        custom-class="category-cell"
      />
      <scale-image
        :src="shop.recommend.thumb"
        :ratio="3"
        radius="5px"
      />
      <double-fence :items="shop.categorys" />
    </div>
    <block
      v-for="(item,index) in items"
      :key="index"
    >

      <view class="item-ans">
        <view class="avatar">
          <image
            class="img"
            src="http://oss.youmbe.com/attachments/avatar/29.jpg"
          />
        </view>
        <view class="expertInfo">
          <view class="name">{{item.title}}</view>
          <view class="tag">{{item.description}}</view>
          <view class="answerHistory">{{item.description}}</view>
        </view>
        <navigator
          url="/pages/askExpert/expertDetail"
          class="askBtn"
        >问TA</navigator>
      </view>
    </block>
  </scroll-view>
</template>

<script>
import Column from '@/components/column/index'
import ScaleImage from '@/components/scaleImage'
import DoubleFence from '@/components/doubleFence'
import GroupCell from '@/components/groupCell'
export default {
  components: {
    Column,
    ScaleImage,
    DoubleFence,
    GroupCell
  },
  props: {
    url: {
      type: String,
      default: ''
    },
    className: {
      type: String,
      default: ''
    },
    scroll: {
      type: Object,
      default: {
        x: false,
        y: true
      }
    }
  },
  data () {
    return {
      yuntuan: {
        title: '加入云团',
        description: '爱运动进云团',
        groups: [
          {
            title: '云库派',
            thumb: 'http://oss.youmbe.com/attachments/temp/group/01.png'
          },
          {
            title: '极光隧道',
            thumb: 'http://oss.youmbe.com/attachments/temp/group/02.png'
          }
        ],
        avatars: [
          'http://oss.youmbe.com/attachments/avatar/06.jpg',
          'http://oss.youmbe.com/attachments/avatar/06.jpg',
          'http://oss.youmbe.com/attachments/avatar/04.jpg',
          'http://oss.youmbe.com/attachments/avatar/03.jpg',
          'http://oss.youmbe.com/attachments/avatar/02.jpg'
        ],
        mark: '65万云团成员',
        link: '加入云团'
      },
      shop: {
        recommend: {
          thumb: '/static/images/banner/01.jpg',
          link: ''
        },
        categorys: [
          {
            id: 1,
            title: '随后拍',
            price: '￥100',
            thumb: '/static/images/1.png',
            description: '随时随地，想拍就拍'
          },
          {
            id: 2,
            title: '信息发布',
            price: '￥500',
            thumb: '/static/images/2.png',
            description: '最新的消息都属于你'
          },
          {
            id: 3,
            title: '投票',
            price: '￥200',
            thumb: '/static/images/3.png',
            description: '为他投上一票'
          },
          {
            id: 4,
            title: '抽奖',
            price: '￥1480',
            thumb: '/static/images/4.png',
            description: '惊喜好运在这里'
          }
        ]
      },
      topics: [
        {
          title: '同城约球急需场馆，帮帮忙啦',
          thumb: 'http://oss.youmbe.com/attachments/temp/swiper/01.png',
          tag: '火爆',
          partakes: 2815
        },
        {
          title: '世界杯预选赛看过来，希望在哪？',
          thumb: 'http://oss.youmbe.com/attachments/temp/swiper/02.png',
          tag: '',
          partakes: 2815
        },
        {
          title: '中国足球路在何方？',
          thumb: 'http://oss.youmbe.com/attachments/temp/swiper/03.png',
          tag: '火爆',
          partakes: 2815
        },
        {
          title: '马拉松你跑过几个？',
          thumb: 'http://oss.youmbe.com/attachments/temp/swiper/03.png',
          tag: '火爆',
          partakes: 2815
        }
      ],
      items: [
        {
          id: 1,
          title: '12年前发明“熊猫烧香”病毒的网络天才，坐4年牢后，现状如何？',
          description: '微观影视 1小时前 102评论',
          format: 'banner',
          medias: [
            {
              path: 'http://oss.youmbe.com/attachments/temp/01.jpg',
              format: 'video'
            }
          ]
        },
        {
          id: 2,
          title: '济南东部房价“喋喋不休”，西部房价依然坚挺，为何？',
          description: '济南楼市 1小时前 102评论',
          format: 'default',
          medias: [
            {
              path: 'http://oss.youmbe.com/attachments/temp/02.jpg',
              format: 'video'
            }
          ]
        },
        {
          id: 3,
          title: '心寒！市民主动清理黑衣人设置的路障 被暴徒用重器猛击头部',
          description: '环球网国内 7小时前 21评论',
          format: 'default',
          medias: []
        },
        {
          id: 4,
          title: '32核心64线程 AMD锐龙Threadripper 3970X评测',
          description: '中关村在线 12-01 05:27 21评论',
          format: 'fence',
          medias: [
            {
              path: 'http://oss.youmbe.com/attachments/temp/03.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/04.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/05.jpg',
              format: 'image'
            }
          ]
        },
        {
          id: 6,
          title: '32核心64线程 AMD锐龙Threadripper 3970X评测',
          description: '中关村在线 12-01 05:27 21评论',
          format: 'fence',
          medias: [
            {
              path: 'http://oss.youmbe.com/attachments/temp/03.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/04.jpg',
              format: 'image'
            }
          ]
        },
        {
          id: 5,
          title: '国庆七十周年阅兵 显国威、振军威',
          description: '凤凰网 10-01 10:27 12,321评论',
          format: 'grid',
          medias: [
            {
              path: 'http://oss.youmbe.com/attachments/temp/11.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/12.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/13.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/14.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/15.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/16.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/17.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/18.jpg',
              format: 'image'
            },
            {
              path: 'http://oss.youmbe.com/attachments/temp/19.jpg',
              format: 'image'
            }
          ]
        }
      ]
    }
  },
  watch: {},
  computed: {},
  beforeMount () {},
  mounted () {},
  methods: {}
}
</script>

<style lang="less">
.scroll-container {
  height: 100%;
}

.horizontal-scroll-container {
  white-space: nowrap;
  height: 90px;
  overflow-y: hidden;
  margin-bottom: 10px;
}

.topic-item {
  position: relative;
  display: inline-block;
  border-radius: 5px;
  margin-left: 15px;
  overflow: hidden;

  &:last-child {
    margin-right: 15px;
  }
  &::after,
  image {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
  }
  &::after {
    content: "";
    background: rgba(0, 0, 0, 0.8);
  }
  &-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #fff;
    width: 160px;
    height: 90px;
    padding: 10px;
    box-sizing: border-box;
  }
  &__title {
    font-size: 14px;
    width: 100%;
    word-wrap: break-word;
    word-break: break-all;
    white-space: pre-line;
  }
  &__extend {
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .van-tag {
      border-bottom-left-radius: 0;
    }
  }
}

.yuntuan {
  display: flex;
  padding: 15px;
  &-group {
    flex: 2;
    .van-cell {
      padding-left: 5px;
    }
    .van-icon--image {
      width: 24px;
      height: 24px;
      border-radius: 3px;
      overflow: hidden;
    }
  }
  &-box {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-direction: column;
    padding: 0 0 10px;
  }
  &-catename {
    display: flex;
    align-items: center;
    font-size: 16px;
    margin: 0 0 10px;
    font-weight: 600;
    small {
      margin-left: 10px;
      font-size: 12px;
      color: #dcdcdc;
      font-weight: normal;
    }
  }
  &-avatars {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    flex-direction: row-reverse;
    padding-right: 7px;
    span {
      display: inline-block;
      width: 15px;
      image {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        box-shadow: 2px 2px 2px 2px rgba(85, 85, 85, 0.1);
      }
    }
  }
  &-mark {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.5);
  }
}

.item-ans {
  width: 100%;
  display: flex;
  flex-grow: row no-wrap;
  justify-content: space-between;
  padding: 30rpx;
  box-sizing: border-box;
  height: 180rpx;
  align-items: center;
  border-bottom: 1px solid #f2f2f2;
}
.avatar {
  width: 100rpx;
  height: 100rpx;
  position: relative;
  padding-right: 30rpx;
}
.avatar .img {
  width: 100%;
  height: 100%;
}
.avatar .doyen {
  width: 40rpx;
  height: 40rpx;
  position: absolute;
  bottom: -2px;
  right: 20rpx;
}
.expertInfo {
  font-size: 12px;
  flex-grow: 2;
  color: #b0b0b0;
  line-height: 1.5em;
}
.expertInfo .name {
  font-size: 16px;
  color: #000;
  margin-bottom: 6px;
}
.askBtn {
  width: 120rpx;
  height: 60rpx;
  line-height: 60rpx;
  text-align: center;
  font-size: 14px;
  border-radius: 60rpx;
  border: 1px solid #4675f9;
  color: #4675f9;
}
</style>
